import { getMenu } from "../../utils/request"

const state = {
  menu:[],//菜单列表
}

const mutations = {
  changeMenu(state,arr){
    state.menu = arr
  }
}


const actions = {
  menuActions(context){
    // 发起菜单请求
    getMenu({istree:true}).then(res=>{
      context.commit('changeMenu',res.data.list)
    })
  }
}

const getters = {
  menu(state){
    return state.menu
  }
}

export default {
  state,
  mutations,
  actions,
  getters,
  namespaced:true,//使用命名空间
}
